## Title    : DumpBytes
## License  : MIT
## Author   : WingSummer
## Function : Dump the specific count bytes at the VA in a process Memory on Linux
## Written on 2022/8/25

#coding=utf-8

import os
import platform

def main():
    if(platform.system() != 'Linux'):
        service.toast("该脚本只能在 Linux 下使用！")
        return
    if(os.getuid()):
        service.toast("该功能只能在 root 模式下使用！")
        return
    res = BoolResult()
    pid = QtGui.QInputDialog.getInt(None,"打开进程","请输入有效 pid",0,0,2147483647,1,res)
    if(not bool(res)):
        service.toast("用户已取消！")
        return
    filename = f'/proc/{pid}/mem'
    if(not service.requestControl()):
        service.toast("获取文档控制权限失败！")
        return
    controller.openRegionFileGUI(filename,0x400000)
    
## ============= entry ============= ##

main()
    